import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

class MemberPage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('会员中心'),
      ),
      body: ListView(
        children: <Widget>[
          _topHeader(),
          _orderTitle(),
          _orderType(),
          _actionList(),
        ],
      )
    );
  }

  // 头像区域
  Widget _topHeader() {
    return Container(
      width: ScreenUtil().setWidth(750),
      padding: EdgeInsets.all(20.0),
      color: Colors.pinkAccent,
      child: Column(
        children: <Widget>[
          Container(
            margin: EdgeInsets.only(top: 30),
            child: ClipOval(
              child: Image.network('http://test.lazyzzd.cn/avatar/1570545605957.jpg', scale: 2,),
            ),
          ),
          Container(
            margin: EdgeInsets.only(top: 10.0),
            child: Text(
              'Mr Strong',
              style: TextStyle(
                fontSize: ScreenUtil().setSp(36),
                color: Colors.white 
              ),
            ),
          ),
        ],
      ),
    );
  }

  // 我的订单顶部
  Widget _orderTitle() {
    return Container(
      margin: EdgeInsets.only(top: 10.0),
      decoration: BoxDecoration(
        color: Colors.white,
        border: Border(
          bottom: BorderSide(width: 0.5, color: Colors.black12)
        )
      ),
      child: ListTile(
        leading: Icon(Icons.list),
        title: Text('我的订单'),
        trailing: Icon(Icons.chevron_right),
      ),
    );
  }

  // 订单列表区域
  Widget _orderType() {
    return Container(
      margin: EdgeInsets.only(top: 5.0),
      width: ScreenUtil().setWidth(750),
      height: ScreenUtil().setHeight(150),
      padding: EdgeInsets.only(top: 20.0),
      color: Colors.white,
      child: Row(
        children: <Widget>[
          _orderItem(Icons.party_mode, '待付款'),
          _orderItem(Icons.query_builder, '待发货'),
          _orderItem(Icons.directions_car, '待收货'),
          _orderItem(Icons.content_paste, '待评价'),
        ],
      ),
    );
  }

  // 订单列表子项
  Widget _orderItem(IconData icon, String desc) {
    return Container(
      width: ScreenUtil().setWidth(187),
      child: Column(
        children: <Widget>[
          Icon(
            icon,
            size: 30,
          ),
          Text(desc),
        ],
      ),
    );
  }

  // listtile通用方法
  Widget _listTileItem(String title) {
    return Container(
      decoration: BoxDecoration(
        color: Colors.white,
        border: Border(
          bottom: BorderSide(color: Colors.black12)
        ),
      ),
      child: ListTile(
        leading: Icon(Icons.blur_circular),
        title: Text(title),
        trailing: Icon(Icons.chevron_right),
      ),
    );
  }

  // List列表
  Widget _actionList() {
    return Container(
      margin: EdgeInsets.only(top: 10.0),
      child: Column(
        children: <Widget>[
          _listTileItem('领取优惠券'),
          _listTileItem('已领取优惠券'),
          _listTileItem('地址管理'),
          _listTileItem('关于我们'),
        ],
      ),
    );
  }
}